package com.itheima.easyexceldemo.controller;

import com.itheima.easyexceldemo.pojo.Result;
import com.itheima.easyexceldemo.service.ExcelService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * excel操作控制器
 *
 * @Author mr.luo
 * @Date 13 4月 2025 01:06
 */
@RestController
public class ExcelController {
    @Autowired
    private ExcelService excelService;

    /**
     * easyexcel导出部门数据
     *
     */
    @GetMapping("/exportDept")
    public Result exportDept(HttpServletResponse response) throws IOException {
        excelService.exportDept(response);
        return Result.success();
    }

    /**
     * easyexcel导入部门数据
     *
     */
    @PostMapping("/importDept")
    public Result importDept(MultipartFile file) throws IOException {
        excelService.importDept(file);
        return Result.success();
    }

}
